<template>
  <div class="container">
    <!-- 内容部分 -->
    <div class="operate">
      <slot></slot>
      <div style="margin-left: auto">
        <el-select
          v-model="value"
          size="small"
          placeholder="Select"
          style="width: 120px"
        >
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </div>
      <slot name="op"></slot>
    </div>
    <div class="content" :style="{ maxHeight: item.h * 40 - 80 + 'px' }">
      <Chart :spec="spec" />
    </div>
  </div>
</template>

<script setup lang="ts">
  /**
   * @description 业务组件 -- 任务完成情况占比
   */
  import { ref } from "vue";
  import Chart from "./Chart.vue";
  defineProps(["item"]);
  const spec = {
    type: "pie",
    data: [
      {
        id: "id0",
        values: [
          { type: "oxygen", value: "46.60" },
          { type: "silicon", value: "27.72" },
          { type: "aluminum", value: "8.13" },
          { type: "iron", value: "5" },
          { type: "calcium", value: "3.63" },
          { type: "sodium", value: "2.83" },
          { type: "potassium", value: "2.59" },
          { type: "others", value: "3.5" },
        ],
      },
    ],
    outerRadius: 0.8,
    valueField: "value",
    categoryField: "type",
    legends: {
      visible: true,
      orient: "top",
      position: "start",
    },
    label: {
      visible: true,
    },
    tooltip: {
      mark: {
        content: [
          {
            key: (datum) => datum["type"],
            value: (datum) => datum["value"] + "%",
          },
        ],
      },
    },
  };

  const value = ref("");

  const options = [
    {
      value: "Option1",
      label: "全部人员",
    },
    {
      value: "Option2",
      label: "部分人员",
    },
  ];
</script>

<style scoped lang="scss">
  .container {
    user-select: none;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0px 10px 10px;
    font-size: 14px;
    color: #999;
    .content {
      flex: 1;
      display: flex;
      flex-direction: column;
      margin-top: 10px;
      overflow: hidden;
    }
  }

  .content-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
  }
  .content-item-main {
    display: flex;
    flex-direction: column;
  }
  .operate {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
  }
</style>
